﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace SaaS
{
    public partial class Dictionary : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            MiniSaaSDB db = new MiniSaaSDB();
            SqlDataReader reader;
            string nextID;
            db.open();
            reader = db.executeQuery("SELECT MAX(Entry_ID)+1 FROM DICTIONARY;");
            if (!reader.HasRows)
            {
                nextID = "1";
            }
            else
            {
                reader.Read();
                if (reader[0] == null || reader[0].ToString().Equals(""))
                    nextID = "1";
                else
                    nextID = reader[0].ToString();
            }
            db.executeNonQuery("INSERT INTO DICTIONARY (Entry_ID, Input, " +
                "Output) VALUES (" + nextID.ToString() +
                ", '" + txtInput.Text.Trim() + "', '" + txtOutput.Text.Trim() + "');");
            db.close();
            GridView1.DataBind();
            txtInput.Text = "";
            txtOutput.Text = "";
        }

    }
}
